package com.yichi.global;

import com.serotonin.modbus4j.code.DataType;
import com.yichi.YiChiApplication;
import com.yichi.util.SPUtil;

/**
 * app配置文件
 */
public class AppConfig {

    //换电柜id
    public static String DEVICE_ID = "YCHDJSNJ000001";

    //平台
    public static String PLATFORM_BASEURL = "https://shareenergy2.test.91wlc.com";//baseUrl
    public static String base64ImageQR = "";//二维码BASE64
    public static String platFormToken = "T+O+NHTzoSgRcXuVMMA/Qw==";//平台token

    //充电阈值
    public static int RECHARGE_SOC_LIMIT = 80;//充到这个电量停止充电

    //plc modbus tcp设备配置
    public static String PLC_MODBUS_HOST = "192.168.10.1";
    public static int PLC_MODBUS_PORT = 502;
    public static int PLC_MODBUS_REQUEST_TIMEOUT = 1000;//modbus请求超时时间
    public static int PLC_MODBUS_SLAVE_ID = 1;//从站地址slaveId
    public static int PLC_MODBUS_HEARTBEAT_OFFSET = 0;//心跳偏移量offset
    public static int PLC_MODBUS_HEARTBEAT_DATATYPE = DataType.TWO_BYTE_INT_UNSIGNED;//心跳数据类型

    //pcb modbus rtu设备配置
    public static int PCB_MODBUS_SLAVE_ID = 20;//从站地址
    public static String PCB_MODBUS_PORTNAME = "/dev/ttyS0";//串口名
    public static int PCB_MODBUS_BAUDRATE = 115200;//波特率
    public static int PCB_MODBUS_DATA_BITS = 8;//数据位
    public static int PCB_MODBUS_STOP_BITS = 1;//停止位
    public static int PCB_MODBUS_PARITY = 0;//校验位
    public static int PCB_MODBUS_REQUEST_TIMEOUT = 1000;//请求超时时间

    //iccard 串口配置
    public static int ICCARD_SLAVE_ID = 11;//从站地址
    public static String ICCARD_PORTNAME = "/dev/ttyS5";//串口名
    public static String ICCARD_BAUDRATE = "115200";//波特率
    public static int ICCARD_DATA_BITS = 8;//数据位
    public static int ICCARD_STOP_BITS = 1;//停止位
    public static int ICCARD_PARITY = 0;//校验位
    public static int ICCARD_REQUEST_TIMEOUT = 1000;//请求超时时间

    //mqtt配置
    public static String MQTT_CLIENT_ID = "cabinet_";
    public static String MQTT_BROKER_URL = "tcp://59.110.126.129:1883";
    public static String MQTT_USERNAME = "";
    public static String MQTT_PASSWORD = "";

    //加载平台地址
    public static void loadPlaformBaseURL() {
        String url = SPUtil.get(YiChiApplication.application, LocalStorageKey.KEY_PLATFORM_BASEURL, "https://shareenergy2.test.91wlc.com");
        PLATFORM_BASEURL = url;
    }

    //保存平台地址
    public static void savePlaformBaseURL(String url) {
        SPUtil.set(YiChiApplication.application, LocalStorageKey.KEY_PLATFORM_BASEURL, url);
        PLATFORM_BASEURL = url;
    }

}
